/**
 * Copyright 2011 Alex Vikulov (vikuloff@gmail.com)

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 */

package com.vvip.stockhart.point;

public class CustomPoint 
{	
	private final Object fID;	
	
	public final double[] Values;
	
	public CustomPoint(Object id,int valueCount)
	{
		fID = id;
		Values = new double[valueCount];
	}
	
	public CustomPoint(Object id,double[] values)
	{
		this(id,values.length);
		setValues(values);
	}
	
	public void setValues(double[] values)
	{
		System.arraycopy(values, 0, Values, 0, Values.length);
	}
	
	public double[] getMaxMin()
	{
		double high = Double.NaN;
		double low = Double.NaN;
		
		for(double d: Values)
		{
			high = (0 == Double.compare(high, Double.NaN))?d:Math.max(high, d);
			low = (0 == Double.compare(low, Double.NaN))?d:Math.min(low, d);
		}	
		
		return new double[] { high, low };
	}
	
	public Object getID()
	{
		return fID;
	}	
}
